

<%@ page import="com.surelution.projects.crm.MessageBoard" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'messageBoard.label', default: 'MessageBoard')}" />
        <title><g:message code="default.create.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <g:if test="${messageBoardInstance.replyTo==null}">
            	<h1><g:message code="default.messageBoard.label" /></h1>
            </g:if>
            <g:if test="${messageBoardInstance.replyTo!=null}">
            	<h1><g:message code="default.message.label" /></h1>
            </g:if>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${messageBoardInstance}">
            <div class="errors">
                <g:renderErrors bean="${messageBoardInstance}" as="list" />
            </div>
            </g:hasErrors>
            
            <g:if test="${messageBoardInstance.replyTo}">
	            <div class="dialog" style="color:black;" >
	                <table style="width:500px;">
						<tbody>
	                    	<tr class="prop">
	                            <td valign="top" style="font-weight:bold;font-family:楷体, arial, helvetica, sans-serif;text-align:left;">
	                            	<g:if test="${messageBoardInstance.replyTo?.title.size()>=10}"><label title="${messageBoardInstance.replyTo?.title}" style="color:#16457d;">${messageBoardInstance.replyTo?.title.substring(0,9)}</label> </g:if>
	                           		<g:if test="${messageBoardInstance.replyTo?.title.size()<10}"><label style="color:#16457d;">${messageBoardInstance.replyTo?.title}</label></g:if>
	                            	(发布者:<label title="${messageBoardInstance.replyTo?.replyTo?.station?.name}">${messageBoardInstance.replyTo?.user})</label>
	                              	<g:link action="show" id="${messageBoardInstance.replyTo?.id}">详情</g:link>
	                            </td>
	
	                            <td valign="top" style="color:gray;text-align:right;"><g:formatDate date="${messageBoardInstance.replyTo?.createTime}" /></td>
								
	                        </tr>
	                        
	                        <tr class="prop">
	                            <td valign="top" class="name2" >
	                            	<g:if test="${messageBoardInstance.replyTo?.description.size()>=15}"><label title="${messageBoardInstance.replyTo?.description}" >${messageBoardInstance.replyTo?.description.substring(0,15)}……</label> </g:if>
	                           		<g:if test="${messageBoardInstance.replyTo?.description.size()<15}"><label>${messageBoardInstance.replyTo?.description}</label></g:if>
	                           	</td>
	                           	 <td valign="top" class="value2" style="width:200px;text-align:right;">
	                           	</td>
	                           	
	                        </tr>
	                    </tbody>
	                </table>
	            </div>
	            <g:if test="${replyList}">
            	<div style="height:30px;">
		            <h1><g:message code="default.replyMessage.label" /></h1>
				</div>

            	<g:each in="${replyList}" var="r">
		            <div class="dialog">
		                <table style="width:500px;">
		                    <tbody>
			                    <tr class="prop">
		                            <td valign="top" align="left" style="font-weight:bold;font-family:楷体, arial, helvetica, sans-serif;text-align:left;">
		                            	<g:if test="${r.title.size()>=10}"><label title="${r.title}" style="color:#16457d;">${r.title.substring(0,9)}</label> </g:if>
		                           		<g:if test="${r.title.size()<10}"><label style="color:#16457d;">${r.title}</label></g:if>
		                            	(发布者:<label title="${r.station?.name}">${r.user})</label>
  		                              	<g:link action="show" id="${r.id}">详情</g:link>
		                            </td>
		
		                            <td valign="top" style="color:gray;text-align:right;"><g:formatDate date="${r.createTime}" /></td>
									
		                        </tr>
		                        
		                        <tr class="prop">
		                            <td valign="top" class="name2" >
		                            	<g:if test="${r.description.size()>=15}"><label title="${r.description}" >${r.description.substring(0,15)}……</label> </g:if>
		                           		<g:if test="${r.description.size()<15}"><label >${r.description}</label></g:if>
		                           	</td>
		                           	<td valign="top" class="value2" style="width:200px;text-align:right;">
		                           		<sec:ifAnyGranted roles="ROLE_ADMIN">
											<g:form style="width:150px;text-align:right;">
							                    <g:hiddenField name="id" value="${r.id}" />
							                    <g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
				                    			<g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'edit')}"/>
						               		</g:form>
						               	</sec:ifAnyGranted>
		                           	</td>
		                           	
		                        </tr>
		                        
		                    </tbody>
		                </table>

		            </div>
	            </g:each>
	            </g:if>
				<div style="height:30px;">
		            <h1><g:message code="default.newReply.label" /></h1>
				</div>

            </g:if>
            <g:form action="save" >
                <div class="dialog">
                    <table style="width:500px;">
                        <tbody>
							<tr class="prop">
                                <td valign="top" class="name">
                                    <label for="title"><g:message code="messageBoard.title.label" default="Title" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: messageBoardInstance, field: 'title', 'errors')}" style="width:200px;">
                                	<g:hiddenField name="replyTo.id" value="${messageBoardInstance?.replyTo?.id }"/>
                                    <g:textField name="title" value="${messageBoardInstance?.title}" style="width:220px;" />(必填)
                                </td>
                            </tr>    
                                                
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="description"><g:message code="messageBoard.description.label" default="Description" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: messageBoardInstance, field: 'description', 'errors')}">
                                    <g:textArea name="description" rows="8" cols="50" value="${messageBoardInstance?.description}" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="buttons" style="width:500px;">
                    <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
